// TicTacToe.h
//
// This header file establishes some constants that should be used in the TicTacToe project for COMP 311
#include <WinSock2.h>
#include <string>


// These 2 settings may have to be changed:
static char broadcastAddress[] = "10.1.255.255"; 	// Must be set to reflect the broadcast address of current LAN
static char NIM_UDPPORT[] = "29333";			// Port number used by Nim servers
static char NIM_TCPPORT[] = "29334";	

#define NIM_QUERY  "Name?"
#define NIM_NAME "Name="
#define NIM_CHALLENGE "Play? Name="
#define NIM_GREAT "GREAT!"

const int MAX_SEND_BUF  = 2048;
const int MAX_RECV_BUF  = 2048;
const int MAX_TCP_MESSAGE = 83;
const int MAX_SERVERS   = 100;
const int MAX_SERVER_NAME = 80;
const int MAX_HOST_SIZE = 16;
const int MAX_SERVICE_SIZE = 80;

const int CLIENT_PLAYER = 1;
const int SERVER_PLAYER = 2;

const int ABORT    = -1;
const int noWinner = 0;
const int xWinner  = 1;
const int oWinner  = 2;
const int TIE      = 3;

static char board[19];
#define MAX_PILES 9
#define MAX_ROCKS_PER_PILE 20
#define MIN_PILES 3
#define MIN_ROCKS_PER_PILE 1
#define MAX_BOARD_SIZE 19

struct ServerStruct {
	char name[MAX_SERVER_NAME];
	char host[MAX_HOST_SIZE];
	char port[MAX_SERVICE_SIZE];
};

// Utility functions for COMP 311 projects
SOCKET connectsock (char*, char*, char*);
SOCKET passivesock (char*, char*);
int UDP_recv (SOCKET, char*, int, char*, char*);
int UDP_send (SOCKET, char*, int, char*, char*);
int TCP_send(SOCKET,char*,int);
int TCP_recv(SOCKET,char*,int,int);
int wait(SOCKET, int, int);

// Functions specifically used by this project
int server_main(int, char*[],std::string);
int client_main(int, char*[],std::string);
void getServers(SOCKET, char*, char*, ServerStruct[], int&);
int playNim(SOCKET, char*, char*, char*, int,std::string);

